﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Xml;

namespace ConsoleExample
{
    class Program
    {
        private static Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();

        static void Main(string[] args)
        {
            FoNetParser.Parser.FoToRtf(FoExample, @"C:\", "Testing.rtf");
            FoNetParser.Parser.HtmlToXslFo(HtmlExample, @"C:\", "Testing.fo");
            FoNetParser.Parser.FoToHtml(FoExample, @"C:\", "Testing.html");
        }

        internal static XmlReader FoExample
        {
            get
            {
                return GetXmlDocument("FoExample.xml");
            }
        }

        internal static XmlReader HtmlExample
        {
            get
            {
                return GetXmlDocument("HtmlExample.htm");
            }
        }

        internal static XmlReader GetXmlDocument(string name)
        {
            try
            {
                var stream = assembly.GetManifestResourceStream(string.Format("{0}{1}", "ConsoleExample.Examples.", name));
                var settings = new XmlReaderSettings { DtdProcessing = DtdProcessing.Ignore };
                return XmlReader.Create(stream, settings);
            }
            catch (Exception ex)
            {
                throw new FileNotFoundException("Unable to find file in assemebly", name);
            }
        }
    }
}
